﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OracleClient;
using System.Data;

namespace DataAccess
{
    public sealed class QueryParameter
    {
        /// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="ParameterName">参数名称</param>
		/// <param name="Value">参数值</param>
		public QueryParameter(string ParameterName,object Value)
		{
			init(ParameterName,Value);
			this.m_Direction=ParameterDirection.Input;
			this.m_OrclType=(OracleType)(-1);
		}
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="ParameterName">参数名称</param>
		/// <param name="Value">参数值</param>
		/// <param name="direction">参数传递方向</param>
		public QueryParameter(string ParameterName,object Value,ParameterDirection direction)
		{
			init(ParameterName,Value);
			this.m_Direction=direction;
			this.m_OrclType=(OracleType)(-1);
		}
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="ParameterName">参数名称</param>
		/// <param name="Value">参数值</param>
		/// <param name="orclType">OracleType枚举,参数的数据类型</param>
		/// <param name="direction">参数传递方向</param>
		public QueryParameter(string ParameterName,object Value,OracleType orclType,ParameterDirection direction)
		{
			init(ParameterName,Value);
			this.m_Direction=direction;
			this.m_OrclType=orclType;
			
		}
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="ParameterName">参数名称</param>
		/// <param name="Value">参数值</param>
		/// <param name="db2Type">DB2Type枚举,参数的数据类型</param>
		/// <param name="direction">参数传递方向</param>
        //public QueryParameter(string ParameterName,object Value,DB2Type db2Type,ParameterDirection direction)
        //{
        //    init(ParameterName,Value);
        //    this.m_Direction=direction;
        //    this.m_db2Type=db2Type;
        //}
		/// <summary>
		/// 初始化参数
		/// </summary>
		/// <param name="ParameterName">参数名称</param>
		/// <param name="Value">参数的值</param>
		private void init(string ParameterName,object Value)
		{
			if(PersistenceProperty.DatabaseType==DatabaseType.MSSQLServer
				||PersistenceProperty.DatabaseType==DatabaseType.DB2)
			{
				this.m_ParameterName=ParameterName.Replace(":","@");
				this.m_Value=Value;
			}
			else
			{
				this.m_ParameterName=ParameterName.Replace("@",":");
				this.m_Value=Value;
			}
		}
		private string m_ParameterName ;
		/// <summary>
		/// 参数名称
		/// </summary>
		public string ParameterName 
		{
			get{return this.m_ParameterName;}
			set{this.m_ParameterName=value;}
		}

		private object m_Value;
		/// <summary>
		/// 参数的值
		/// </summary>
		public object Value
		{
			get{return this.m_Value;}
			set{this.m_Value=value;}
		}
		private ParameterDirection m_Direction;
		/// <summary>
		/// 参数传递方向
		/// </summary>
		public ParameterDirection Direction
		{
			get{return this.m_Direction;}
			set{this.m_Direction=value;}
		}
		private OracleType m_OrclType;
		/// <summary>
		/// Oracle数据类型
		/// </summary>
		public OracleType OrclType
		{
			get{return m_OrclType;}
			set{m_OrclType=value;}
		}
        //private DB2Type m_db2Type;
		/// <summary>
		/// DB2数据类型
		/// </summary>
        //public DB2Type Db2Type
        //{
        //    get{return m_db2Type;}
        //    set{m_db2Type=value;}
        //}
	}
    
}
